package com.cardbaobao.cardbabyclient.ui.pop;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.cardbaobao.cardbabyclient.R;

/**
 * Created by Jiangzx on 2017/9/12 10:43.
 */

public abstract class ListPop extends PopupWindow {
    private TextView tvTitle;
    public ListPop(Context context){
        View root= LayoutInflater.from(context).inflate(R.layout.pop_list_view,null);
        root.findViewById(R.id.ibt_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        tvTitle= (TextView) root.findViewById(R.id.tv_title);
        ListView listView= (ListView) root.findViewById(R.id.list_view);
        configListView(listView);
        setContentView(root);
        setWidth(WindowManager.LayoutParams.MATCH_PARENT);
        setHeight(WindowManager.LayoutParams.MATCH_PARENT);
        setBackgroundDrawable(new ColorDrawable());
        setAnimationStyle(R.style.CustomBottomAnimateStyle);
        setClippingEnabled(false);
    }

    /**
     * 设置标题
     * @param title 标题
     */
    public void setTitle(CharSequence title){
        if(tvTitle!=null&&!TextUtils.isEmpty(title)){
            tvTitle.setText(title);
        }
    }

    public abstract void configListView(ListView listView);
}
